********************************************************************************

* Filename: Table_3_TeacherAssessments.do

********************************************************************************
*  This do-file is part of the collection of replication files for Schaffner, Glewwe, and Sharma, 
*  "Why Programs Fail:  Lessons for Improving Public Service Quality from a Mixed Methods Evaluation
*   of an Unsuccessful Teacher Training Program in Nepal"
*
*This do-file calculates:
*      Descriptive statistics related to anonymous teacher responses to questions 
*      evaluating students assessment items (indirectly testing teacher subject knowledge)
*	   Some of these are reported in Table 3 of the journal article.
*
* Software version used: STATA/SE 18.0
********************************************************************************
*GLOBAL FILE PATH DEFINITIONS
	global PBRfolder "ADD FILE REFERENCE TO MAIN FOLDER HERE" 
	global datasets = "$PBRfolder\Datasets"
	global logs = "$PBRfolder\Logs"

********************************************************************************
* SET-UP
	set more off
	clear all
	set varabbrev on
	capture log close
	log using "$logs\Table_3_calcs", replace
	cd "$datasets"

********************************************************************************

*MATH TEACHER RESPONSES 

********************************************************************************

	* READ IN MATH TEACHER REPSONSES TO "TEACHER EVALUATION OF MATH ASSESSMENT ITEMS"

		use Teachereval_math_c, clear

		*Rename the variables in a way that will be good for looping and re-shaping, and look at descriptive statistics 
		local i=1    // indexes assessment item
		while `i'<=12 {
			gen m_clear_`i'=t_math_`i'_a==1 if t_math_`i'_a~=. //question was clear to the teacher
			replace t_math_`i'_correct=. if t_math_`i'_b==.   // which answer do you think is right answer?
			gen m_correct_`i'=t_math_`i'_correct  // picked right answer
			gen m_approp_`i'=t_math_`i'_d==1 //appropriate for testing curriculum
			gen m_stupct_`i'=t_math_`i'_c // guess about percent of students who will get correct
			local i=`i' +1
			}
			
		unique schoolid // 189 schools, 246 records/teachers who filled out evaluations
		sort schoolid
		by schoolid: gen num=_N
		tab num  // 59 percent of schools have only one teacher math evaluation, but there are up to 4 in a school

		summ m_clear* m_correct* m_approp* m_stupct*

		* gather up means and save them in variables (each with 12 observations for the 12 questions)
		gen question=0
		gen nresponding=0
		gen pctcorrect=0
		gen pctclear=0
		gen pctapprop=0
		gen medstupct=0
		local i=1
		while `i'<=12 {
			replace question=`i' if _n==`i'
			summ m_correct_`i'
			replace nresponding=r(N) if _n==`i'
			replace pctcorrect=r(mean)*100 if _n==`i'
			summ m_clear_`i'
			replace pctclear=r(mean)*100 if _n==`i'
			summ m_approp_`i'
			replace pctapprop=r(mean)*100 if _n==`i'
			summ m_stupct_`i', detail
			replace medstupct=r(p50) if _n==`i'
			local i=`i'+1
			}
		format pctcorrect pctclear pctapprop %5.1f
			format %6.0f nresponding
		list question nresponding pctcorrect pctclear pctapprop medstupct in 1/12

	*Assessment items
		/*
		Math
		t_math_1: Which of these has the same value as 342?...
		t_math_2: All of the students in a class cut out paper shapes...
		t_math_3: It takes Diksha 4 minutes to wash a window...  
		t_math_4: Which of the numbers below is equal to 7/10 ?...
		t_math_5: There were m boys and n girls in a parade.... 
		t_math_6: What is 15 × 9? ...
		t_math_7: Which of these is the reason that triangle...
		t_math_8: A thin wire 20 centimeters long is formed into a rectangle...
		t_math_9: If x + 3y = 11 and 2x + 3y = 13, then y = ? ...
		t_math_10: The bearing of a school from your house is 120°...
		t_math_11: If the volume of a cube is 216 cubic cm...
		t_math_12: What is the sum of mode and median of the following data?...
		*/

	* LIST PERCENT CORRECT FOR THE ITEMS IN TABLE 3, IN THE ORDER PRESENTED THERE

		di pctcorrect[2] "  " nresponding[2] _newline ///
		pctcorrect[6] "  " nresponding[6] _newline ///
		pctcorrect[11] "  " nresponding[11] _newline ///
		pctcorrect[9] "  " nresponding[9] _newline ///
		pctcorrect[8] "  " nresponding[8] 
	
	
********************************************************************************

*SCIENCE TEACHER RESPONSES 

********************************************************************************

	* READ IN SCIENCE TEACHER REPSONSES TO "TEACHER EVALUATION OF MATH ASSESSMENT ITEMS"

		use Teachereval_science_c, clear

		*Rename the variables in a way that will be good for looping and re-shaping, and look at descriptive statistics 
		local i=1    // indexes assessment item
		while `i'<=12 {
			gen s_clear_`i'=t_science_`i'_a==1 if t_science_`i'_a~=. //question was clear to the teacher
			replace t_science_`i'_correct=. if t_science_`i'_b==.   // which answer do you think is right answer?
			gen s_correct_`i'=t_science_`i'_correct  // picked right answer
			gen s_approp_`i'=t_science_`i'_d==1 //appropriate for testing curriculum
			gen s_stupct_`i'=t_science_`i'_c // guess about percent of students who will get correct
			local i=`i' +1
			}
				
		unique schoolid // 186 schools, 234 records/teachers who filled out evaluations
		sort schoolid
		by schoolid: gen num=_N
		tab num  // 63 percent of schools have only one teacher math evaluation, but there are up to 4 in a school

		summ s_clear* s_correct* s_approp* s_stupct*
		
		* gather up means and save them in variables (each with 12 observations for the 12 questions)
		gen question=0
		gen nresponding=0
		gen pctcorrect=0
		gen pctclear=0
		gen pctapprop=0
		gen medstupct=0
		local i=1
		while `i'<=12 {
			replace question=`i' if _n==`i'
			summ s_correct_`i'
			replace nresponding=r(N) if _n==`i'
			replace pctcorrect=r(mean)*100 if _n==`i'
			summ s_clear_`i'
			replace pctclear=r(mean)*100 if _n==`i'
			summ s_approp_`i'
			replace pctapprop=r(mean)*100 if _n==`i'
			summ s_stupct_`i', detail
			replace medstupct=r(p50) if _n==`i'
			local i=`i'+1
			}
		format %5.1f pctcorrect pctclear pctapprop
		format %6.0f nresponding
			
		list question nresponding pctcorrect pctclear pctapprop medstupct in 1/12

	*Assessment items
		/*
		Science
		t_science_1: All living things can be grouped as plants or animals... 
		t_science_2: What is the chemical formula of water?t...
		t_science_3: What is the rate of change in velocity per unit of time? ...
		t_science_4: What is the main function of red blood cells? ...
		t_science_5: Which of the following is the major cause of tides? ...
		t_science_6: What feature is shared by ALL insects? ... 
		t_science_7: Which one of the following statements about liquid evaporation is correct? ...
		t_science_8: Which of the following grows from a seed? ...
		t_science_9: When a small volume of water is boiled, a large volume of steam is produced... 
		t_science_10: Some students used an ammeter A to measure the current in the circuit for different voltages ...
		t_science_11: Which one of the following statements best describes a comet? ...
		t_science_12: The symbol of the element nitrogen is: ...
		*/
		
	* LIST PERCENT CORRECT FOR THE ITEMS IN TABLE 3, IN THE ORDER PRESENTED THERE

		di pctcorrect[3] "  " nresponding[3] _newline ///
		pctcorrect[4] "  " nresponding[4] _newline ///
		pctcorrect[9] "  " nresponding[9] _newline ///
		pctcorrect[7] "  " nresponding[7] _newline 
		
log close